package fiscal.entities.tables;

import java.util.ArrayList;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Id;

import exceptions.PersistenceExceptionMessage;
import fiscal.dao.PersistenceOrigemDestinoICMS;
import fiscal.entities.IDEstadoEstado;
import generic.interfaces.GenericPersistence;
import generic.interfaces.IDEntity;

@Entity
public class OrigemDestinoICMS implements IDEntity<IDEstadoEstado>, GenericPersistence<PersistenceOrigemDestinoICMS , IDEstadoEstado, OrigemDestinoICMS>, Comparable<OrigemDestinoICMS> {

	public static PersistenceOrigemDestinoICMS persist = new PersistenceOrigemDestinoICMS();
	
	@Id
	@EmbeddedId
	private IDEstadoEstado id;
	private Double aliquota;

	
	public IDEstadoEstado getId() {
		return this.id;
	}
	
	
	public void setId(IDEstadoEstado id) {
		this.id = id;
	}
	
	public Double getAliquota() {
		return aliquota;
	}

	public void setAliquota(Double aliquota) {
		this.aliquota = aliquota;
	}

	
	public int compareTo(OrigemDestinoICMS origem) {
		return getId().getOrigem().compareTo(origem.getId().getOrigem());
	}

	
	public PersistenceOrigemDestinoICMS DAOInstance() throws PersistenceExceptionMessage {
		if (persist == null) {
			persist = new PersistenceOrigemDestinoICMS();
		}
		return persist;
	}

	
	public OrigemDestinoICMS find(IDEstadoEstado id)
			throws PersistenceExceptionMessage {
		return DAOInstance().find(id);
	}

	
	public void persist() throws PersistenceExceptionMessage {
		DAOInstance().persist(this);
	}

	
	public void remove() throws PersistenceExceptionMessage {
		DAOInstance().remove(this);
	}

	
	public OrigemDestinoICMS merge() throws PersistenceExceptionMessage {
		return DAOInstance().merge(this);
	}

	
	public ArrayList<OrigemDestinoICMS> findAll()
			throws PersistenceExceptionMessage {
		return (ArrayList<OrigemDestinoICMS>) DAOInstance().findAll();
	}
	
}
